package com.itheima._2_list;

import java.util.ArrayList;

public class practiseList {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 1; i <= 500; i++) {
            list.add(i);
        }
        int count = 0;
        while (list.size() > 1) {
            for (int i = 0; i < list.size(); i++) {
                count++;
                if (i == list.size()-1) {
                    i = 0;
                }
                if (count % 3 == 0) {
                    list.remove(i);
                    i--;
                }
            }
        }
        System.out.println(list);
    }
}
